package com.vf.activity.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.vf.common.annotation.Log;
import com.vf.common.core.controller.BaseController;
import com.vf.common.core.domain.AjaxResult;
import com.vf.common.enums.BusinessType;
import com.vf.activity.domain.Notifications;
import com.vf.activity.service.INotificationsService;
import com.vf.common.utils.poi.ExcelUtil;
import com.vf.common.core.page.TableDataInfo;

/**
 * 通知（用于申请/审核通知）Controller
 * 
 * @author LBS
 * @date 2025-06-04
 */
@RestController
@RequestMapping("/activity/notification")
@Api(tags="通知（用于申请/审核通知）")
public class NotificationsController extends BaseController
{
    @Autowired
    private INotificationsService notificationsService;

    /**
     * 查询通知（用于申请/审核通知）列表
     */
    @PreAuthorize("@ss.hasPermi('activity:notification:list')")
    @GetMapping("/list")
    public TableDataInfo list(Notifications notifications)
    {
        startPage();
        List<Notifications> list = notificationsService.selectNotificationsList(notifications);
        return getDataTable(list);
    }

    /**
     * 导出通知（用于申请/审核通知）列表
     */
    @PreAuthorize("@ss.hasPermi('activity:notification:export')")
    @Log(title = "通知（用于申请/审核通知）", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Notifications notifications)
    {
        List<Notifications> list = notificationsService.selectNotificationsList(notifications);
        ExcelUtil<Notifications> util = new ExcelUtil<Notifications>(Notifications.class);
        util.exportExcel(response, list, "通知（用于申请/审核通知）数据");
    }

    /**
     * 获取通知（用于申请/审核通知）详细信息
     */
    @PreAuthorize("@ss.hasPermi('activity:notification:query')")
    @GetMapping(value = "/{notificationId}")
    public AjaxResult getInfo(@PathVariable("notificationId") Long notificationId)
    {
        return success(notificationsService.selectNotificationsByNotificationId(notificationId));
    }

    /**
     * 新增通知（用于申请/审核通知）
     */
    @PreAuthorize("@ss.hasPermi('activity:notification:add')")
    @Log(title = "通知（用于申请/审核通知）", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Notifications notifications)
    {
        return toAjax(notificationsService.insertNotifications(notifications));
    }

    /**
     * 修改通知（用于申请/审核通知）
     */
    @PreAuthorize("@ss.hasPermi('activity:notification:edit')")
    @Log(title = "通知（用于申请/审核通知）", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Notifications notifications)
    {
        return toAjax(notificationsService.updateNotifications(notifications));
    }

    /**
     * 删除通知（用于申请/审核通知）
     */
    @PreAuthorize("@ss.hasPermi('activity:notification:remove')")
    @Log(title = "通知（用于申请/审核通知）", businessType = BusinessType.DELETE)
	@DeleteMapping("/{notificationIds}")
    public AjaxResult remove(@PathVariable Long[] notificationIds)
    {
        return toAjax(notificationsService.deleteNotificationsByNotificationIds(notificationIds));
    }
}
